// mixins/navbarMixin.js
export default {
  data() {
    return {
      menuButtonInfo: null,
      titleTop: 0,
      statusBarHeight: 0
    }
  },
  onReady() {
    this.calculateNavbarPosition()
  },
  methods: {
    calculateNavbarPosition() {
     let that = this;
     // 获取胶囊按钮位置信息
     const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
     const {
     	top,
     	height
     } = menuButtonInfo;
     const statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
     		
     // 计算标题需要偏移的位置
     const titleTop = top + (height - statusBarHeight) / 2;
	 this.menuButtonInfo = menuButtonInfo
     this.titleTop = titleTop; //设置标题顶部距离
     this.statusBarHeight = statusBarHeight; //设置状态栏高度
    }
  }
}